package com.xu.actdlg;


import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;

public class DlgActivity extends Activity implements DialogCaseListenor{

	private DlgShower dlgShower;
	private TextView textView_content;
	private Button button_ok;
	private Button button_cancel;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_dlg);
		dlgShower=DlgShower.getDlgShowerByID(getDlgID());
		DlgShower.regiserActivity(this);
		
		initView();
	}
	private void initView() {
		textView_content=(TextView) findViewById(R.id.textView_content);
		button_ok=(Button) findViewById(R.id.button_ok);
		button_cancel=(Button) findViewById(R.id.button_cancel);
		textView_content.setText(getIntent().getExtras().getString("dlgTitle"));
		button_ok.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				onClickOK();
			}
		});
		button_cancel.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				onClickCancel();
			}
		});
	}
	
	@Override
	public void onClickOK() {

		if(dlgShower!=null)
			dlgShower.onClickOK();
		dismiss();
	}
	@Override
	public void onClickCancel() {
		if(dlgShower!=null)
			dlgShower.onClickCancel();	
		dismiss();
	}
	@Override
	public void onClickOrther() {
		if(dlgShower!=null)
			dlgShower.onClickOrther();		
		dismiss();
	}
	@Override
	public void onClickClose() {
		if(dlgShower!=null)
			dlgShower.onClickClose();	
		dismiss();
		
	}
	@Override
	public String getDlgID() {
		if( getIntent().getExtras()!=null)
			return getIntent().getExtras().getString("dlgID");
		return null;
	}
	@Override
	public void dismiss() {
		finish();
	}
	@Override
	protected void onDestroy() {
		DlgShower.unRegiserActivity(this);
		super.onDestroy();
	}
	
	
}
